import {
	devHttp
} from '@/services/hbhttp.js'
const $http = devHttp;

/**
 *  新建更新活动
 */
export const postSaveOrUpdateActivity = (params) => {
	return $http.post('activity/saveOrUpdateActivity', params)
};

/**
 *  查询活动列表
 */
export const getActivityList = (params) => {
	return $http.post('activity/getActivityList', params)
};

/**
 *  用户查询活动列表
 */
export const getUserActivityList = (params) => {
	return $http.post('admin/getActivityList', params)
};

/**
 *  添加修改参赛人员信息
 */
export const postSaveOrUpdateCompete = (params) => {
	return $http.post('admin/saveOrUpdateCompete', params)
};

/**
 *  删除文件
 */
export const postFileDelete = (params) => {
	return new Promise((resolve, reject) => {
		uni.request({
		  url: 'https://limsapi.gzhbcss.com/file/delete',
		  method: 'POST', // 设置为POST请求
		  data: params,
		  header: {
		    'Content-Type': 'application/json', // 如果是普通的POST请求，Content-Type通常是application/json
		  },
		  success: (uploadResult) => {
		    resolve(uploadResult); // 删除成功
		  },
		  fail: (error) => {
		    reject(error); // 删除失败
		  }
		});
	});
};


// 上传文件
export const postFileInsert = (filePath) => {
	return new Promise((resolve, reject) => {
		uni.uploadFile({
			url: 'https://limsapi.gzhbcss.com/file/insert',
			filePath: filePath,
			name: 'file',
			header: {
				'Content-Type': 'multipart/form-data',
			},
			success: (uploadResult) => {
				resolve(uploadResult); // 上传成功
			},
			fail: (error) => {
				reject(error); // 上传失败
			}
		});
	});
}